import csv
import pandas as pd

Region_info = [[(0, 9), (0, 142), (18, 9), (18, 142)],  # 公司
               [(93, 42), (56, 42), (93, 73), (56, 73)],
               [(283, 66), (300, 66), (283, 107), (300, 107)],
               [(396, 66), (300, 66), (300, 107), (396, 107)],
               [(396, 107), (396, 153), (331, 153), (331, 107)],
               [(18, 9), (56, 9), (18, 108), (56, 108)],  # 饭店
               [(331, 107), (300, 107), (331, 139), (300, 139)],
               [(300, 139), (283, 139), (300, 153), (283, 153)],
               [(331, 50), (396, 50), (331, 66), (396, 66)],
               [(430, 139), (430, 153), (396, 139), (396, 153)]]



def is_coordinate_in_region(coordinate, region):
    x, y = coordinate
    x_min, y_min = min(region, key=lambda point: point[0])
    x_max = max(region, key=lambda point: point[0])[0]
    y_max = max(region, key=lambda point: point[1])[1]
    print(x, x_min, x_max, y, y_min, y_max)
    if x_min <= x <= x_max and y_min <= y <= y_max:
        return True
    else:
        return False

# 使用函数找出各个区域内的标号坐标
companies_labels = ["公司", 5, 6, 7, 27, 28, 21, 11, 12, 13, 14, 113, 82, 83, 84, 85, 86, 87, 88, 89, 102, 91, 92, 93, 94, 95, 96, 110, 98, 99, 111, 20]
restaurants_labels = ["饭店", 16, 17, 18, 19, 81, 10, 22, 23, 24, 25, 26, 8, 9, 101, 90, 103, 105, 106, 109, 97, 100]

# 读取 CSV 文件为 DataFrame
data = pd.read_csv('map.csv', header=None)  # 假设 CSV 文件没有标题行
map_matrix = data.values
# 对地图矩阵进行转置
map_matrix = map_matrix.transpose()
results = []
# 遍历 DataFrame 的行和列
check_list = [113, 93, 94, 110, 98, 91, 108, 107, 95, 92, 96, 111, 99]
for i in range(map_matrix.shape[0]):  # 遍历行数
    for j in range(map_matrix.shape[1]):  # 遍历列数
        cell_value = map_matrix[i][j]  # 获取当前格子的值
        # 在这里根据你的条件判断是否符合要求，这里只是一个示例条件
        if cell_value in check_list:  # 假设符合条件的值为 1
            check_type = (i, j)
            results.append(check_type)
            check_list.remove(cell_value)


print(results)
